home *** CD-ROM | disk | FTP | other *** search
/ Amiga ISO Collection / AmigaUtilCD2.iso / Misc / JOE_SOUR.LHA / Sources.lha / Tempest / tempest->s!xconvert / convert.c next >
Encoding:
C/C++ Source or Header  |  1996-05-02  |  11.5 KB  |  311 lines

  1. #include <exec/types.h>
  2. #include <exec/ports.h>
  3. #include <exec/memory.h>
  4. #include <dos/dos.h>
  5. #include <clib/exec_protos.h>
  6. #include <clib/dos_protos.h>
  7. #include <clib/alib_protos.h>
  8. #include <stdio.h>
  9. #include <stdlib.h>
  10. #include <string.h>
  11. #include <ctype.h>
  12. #include <time.h>
  13. void lowerstring(char *s);
  14. void upperstring(char *s);
  15.  
  16. struct TempUser
  17. {
  18.  UWORD   Slot_Number;            // (  2) Account#
  19.  UBYTE   Status;                 // (  1) 0=Deleted, 1=Active, 2=New User, 3=Locked Out, 4=Created Account
  20.  
  21.  TEXT    Name[31],               // ( 31) Users Name
  22.          RealName[26],           // ( 26) Real Name
  23.          VoicePhone[21],         // ( 21) Voice Phone Number
  24.          DataPhone[21],          // ( 21) Data  Phone Number
  25.          Address[26],            // ( 26) Address
  26.          City[26],               // ( 26) City
  27.          State[4],               // (  4) State/Providence Code
  28.          Country[4],             // (  4) Country Code
  29.          MailRoute[15],          // ( 15) Zip Code / Mail Route
  30.          ComputerType[21],       // ( 21) Computer Type (Possible Code Instead)
  31.          Password[16],           // ( 16) Password
  32.          Comment[31];            // ( 31) Comment String
  33.  
  34.  UBYTE   Security;               // (  1) Access Level
  35.  UWORD   WeedDays,               // (  2) Days of inactivity until bbs auto deletes
  36.          ReduceDays;             // (  2) Days Paid for by a payer.                        (NOT USED YET)
  37.  UBYTE   ReducedAccess;          // (  1) Preset level to give to user after reduced days  (NOT USED YET)
  38.  
  39.  UBYTE   AnsiType,               // (  1) Ansi Type  0) Normal, 1) Amiga, 2) IBM, 3) RIP
  40.          Protocol,               // (  1) Protocol Selected: 0:Zmodem 1:Hydra
  41.          DEADProto,              // (  1) Not Used Anymore
  42.          HelpLevel,              // (  1) Level of Help
  43.          MSGHeader,              // (  1) Msg Header Type
  44.          EditorLines,            // (  1) Max Lines allowed in Editor      (NOT USED YET)
  45.          DescLines,              // (  1) File Listing lines, Descriptions
  46.          ViewMode,               // (  1) File Listing View Mode
  47.          WhoPrefs,               // (  1) Who Preferences
  48.          MB_J,                   // (  1) Message Rejoin
  49.          FB_J,                   // (  1) File rejoin
  50.          Length,                 // (  1) Length of screen
  51.          Width,                  // (  1) Width of screen
  52.          Language,               // (  1)
  53.          Translation,            // (  1) (NOT USED YET)
  54.          TimeZone,               // (  1) Time Zone Offset (NOT USED YET)
  55.          BirthDate_Day,          // (  1) DAY of birth
  56.          BirthDate_Month,        // (  1) MONTH of birth
  57.          BirthDate_Year,         // (  1) YEAR of birth
  58.          IdleTime,               // (  1) Idle time allowed for no activity (NOT USED YET)
  59.          NodeLastOn;             // (  1) Last node user was on
  60.  
  61.  UWORD   ForwardMailSlot,        // (  2) Slot Number of user to forward mail to! (NOT USED YET)
  62.          PWF;                    // (  2) Number of Password Failures
  63.  
  64.  UWORD   Total_Calls,            // (  2) # of Calls Total
  65.          Total_Posts,            // (  2) Msgs left total
  66.          Total_PostsReceived,    // (  2) Msgs Received
  67.          Total_ULFiles,          // (  2) # of Uploads
  68.          Total_DLFiles,          // (  2) # of Downloads
  69.          Total_TimeBank;         // (  2) Time Bank Value
  70.  ULONG   Total_ULBytes,          // (  4) Total Uploaded Bytes
  71.          Total_DLBytes;          // (  4) Total Downloaded Bytes
  72.  
  73.  UWORD   Limit_Calls,            // (  2) Calls ALLOWED per Day
  74.          Limit_Posts,            // (  2) Messages Allowed p/d
  75.          Limit_ULFiles,          // (  2) # of Uploads Per Period
  76.          Limit_DLFiles,          // (  2) # of Downloads Per Period
  77.          Limit_Time,             // (  2) Time Limit per day.
  78.          Limit_TimeBank,         // (  2)
  79.          Limit_ChatTime;         // (  2) Limit of Time user can be in chat door
  80.  ULONG   Limit_ULBytes,          // (  4) Limit Upload Bytes Per Period
  81.          Limit_DLBytes;          // (  4) Limit Download Bytes Per Period
  82.  
  83.  UBYTE   F_Ratio,                // (  1) File Ratio
  84.          B_Ratio;                // (  1) Byte Ratio
  85.  
  86.  UBYTE   Period_Type;            // (  1) Mins, Hours, Days, Weeks, Months, Years    (NOT USED YET)
  87.  UWORD   Period_Length,          // (  2) 24 hours or whatever! Set Limits by Period (NOT USED YET)
  88.          Period_Calls,           // (  2) Calls made  Today
  89.          Period_Posts,           // (  2) Todays Msgs Sent
  90.          Period_ULFiles,         // (  2) Todays Ul's
  91.          Period_DLFiles,         // (  2) Todays Dl's
  92.          Period_ChatTime;        // (  2) Time user has been in chat this period
  93.  ULONG   Period_ULBytes,         // (  4) Period Bytes Uploaded
  94.          Period_DLBytes;         // (  4) Period Bytes Downloaded
  95.  
  96.  UWORD   Left_DLFiles,           // (  2) Files left available for download
  97.          Left_ChatTime,          // (  2) Limit of Time user can be in chat door
  98.          Left_Time;              // (  2) Time Left
  99.  ULONG   Left_DLBytes;           // (  4) Bytes left for this period
  100.  
  101.  UWORD   DayCredits,             // (  2) For Payers
  102.          FileCredits;            // (  2) Files Paid for by a payer.
  103.  
  104.  ULONG   ByteCredits,            // (  4) Bytes Paid for by a payer.
  105.          PersonalBytes,          // (  4) Personal Area Bytes Limit
  106.          LastBaudRate;           // (  4) Last Baud Rate of a user.
  107.  
  108.  LONG    Time_First_Called,      // (  4) Time First Logged On
  109.          Time_Last_Logoff,       // (  4) Last Time LOGGED OFF
  110.          Time_Last_Connect;      // (  4) Time last CONNECTED
  111.  
  112. LONGBITS UserBitsA,              // (  4)
  113.          UserBitsB,              // (  4)
  114.          UtilBits,               // (  4) 32 bits for Programmers to use as they wish for utils.
  115.          LastCallFlags,          // (  4) Flags for activities during last call. Posted,UL,DL,etc (NOT USED YET)
  116.          CatFlags,               // (  4) Flags for Custom File Listing (NOT USED YET)
  117.  
  118.          NFlags1,                // (  4) Normal Flags Part 1
  119.          NFlags2,                // (  4) Normal Flags Part 2
  120.          SFlags1,                // (  4) Sysop  Flags Part 1
  121.          SFlags2;                // (  4) Sysop  Flags Part 2
  122.  
  123.  char    MsgBase[41],            // (1x41=41) MB 0-39 Flags N,Y,S   // Change to 2 LONGBITS
  124.          FileBase[41];           // (1x41=41) FB 0-39 Flags N,Y,S   // one for normal, one for sysop
  125.  
  126.  UWORD   Last_Read_Message[40],  // (40x2=80) -position change- Last read pointer
  127.          Last_Scan_Message[40];  // (40x2=80)
  128.  
  129.  BYTE    AnsiColor;              // (  1) Ansi Color
  130.  BYTE    BExtras[29];            // (1x29=29)
  131.  
  132.  UWORD   CheckSum,               // (  2)
  133.          SerialNumber;           // (  2) Unique seiral number for flagged files, etc. (NOT USED YET)
  134.  
  135.  SHORT   SExtras[3];             // (3x2=6)
  136.  LONG    LExtras[3];             // (3x4=12)
  137. };
  138.  
  139.  
  140. struct User {
  141.  char    Name[31],Pass[9],Location[30],PhoneNumber[13];
  142.  USHORT  Slot_Number;
  143.  USHORT  Sec_Status,
  144.          Sec_Board,                   /* File or Byte Ratio */
  145.          Sec_Library,                 /* Ratio              */
  146.          Sec_Bulletin,                /* Computer Type      */
  147.          Messages_Posted; /* Note ConfYM = the last msg you actually read, ConfRead is the same ?? */
  148.  ULONG   NewSinceDate;
  149.  ULONG   ConfRead1, ConfRead2, ConfRead3, ConfRead4, ConfRead5,  ConfRead6,
  150.          ConfRead7, ConfRead8, ConfRead9;
  151.  char    Conference_Access[10];
  152.  USHORT  Uploads, Downloads, ConfRJoin, Times_Called;
  153.  long    Time_Last_On, Time_Used, Time_Limit, Time_Total;
  154.  ULONG   Bytes_Download,
  155.      Bytes_Upload,
  156.      Daily_Bytes_Limit,
  157.      Daily_Bytes_Dld;
  158.  char    Expert;
  159.  double  NBytes_Download,        // Bytes Downloaded as a "double"
  160.      NBytes_Upload,            // Bytes Uploaded as a "double"
  161.      NDaily_Bytes_Limit,        // Daily Bytes Limit
  162.      NDaily_Bytes_Dld;        // Bytes Downloaded today.
  163.  UBYTE   Flag1, Flag2, FLag3, EditorType;
  164.  long    BeginLogCall;
  165.  UBYTE   Protocol, UUCPA, LineLength, New_User;
  166.  }; // UUCPA == AnsiUserFlag!
  167. ///
  168. /// Struct for User.keys!
  169. struct UserKeys {                 /* changes to UserKeys (RTS) */
  170.  char    UserName[31];
  171.  long    Number;
  172.  UBYTE   New_User;
  173.  UWORD   UPcps,              /* highest upload cps rate */
  174.          DNcps,              /* highest dnload cps rate */
  175.          Userflags,          /*                         */
  176.          baud_rate;          /* last online baud rate   */
  177.  UBYTE   QFlag,
  178.          Who,
  179.          MailScan,
  180.          Language,
  181.          QuietNode,
  182.          MaxCalls,
  183.          Called,
  184.          ReplySkip;
  185.  char    Pad[1];             /* ?? should be 15         */
  186. };
  187.  
  188.  
  189.  
  190. void main(int argc, char *argv[])
  191. {
  192.  
  193.     char    buffer[255];
  194.     ULONG    slot=1;
  195.     struct    TempUser    *tuser=NULL;
  196.     struct  User        *user=NULL;
  197.     struct    UserKeys    *userkeys=NULL;
  198.     BPTR    readfh=NULL,writefh=NULL,writefh2=NULL;
  199.     
  200.     printf("Convert Tempest Userdata to Sexpress Userdata!\n");
  201.     if (argc!=2)
  202.     {
  203.         printf("Usage: Convert <Tempest Userdata>\n");
  204.         exit(5);
  205.     }
  206.     
  207.     readfh=Open(argv[1],MODE_OLDFILE);
  208.     if (!readfh) 
  209.     {
  210.         printf("Couldn`t open Tempest Datafile!\n");
  211.         exit(5);
  212.     }
  213.  
  214.     writefh=Open("ram:User.data",MODE_NEWFILE);
  215.     writefh2=Open("ram:User.keys",MODE_NEWFILE);
  216.  
  217.     tuser    =(struct TempUser *) malloc (sizeof(struct TempUser));
  218.     user     =(struct     User *) malloc (sizeof(struct     User));
  219.     userkeys=(struct UserKeys *) malloc (sizeof(struct UserKeys));
  220.     
  221.     while (Read(readfh,tuser,sizeof(struct TempUser)))
  222. {
  223.  
  224.     if (tuser->Status==1 || tuser->Status==2 || tuser->Status==4)
  225.     {
  226.  
  227.         printf("Processing: %3d %s\n",slot,tuser->Name);
  228.  
  229.  
  230.         strcpy(user->Name,tuser->Name);
  231.         sprintf(user->Pass,"%.8s",tuser->Password);
  232.         strcpy(user->Location,tuser->City);
  233.         sprintf(user->PhoneNumber,"%.12s",tuser->VoicePhone);
  234.         user->Slot_Number=slot;
  235.         user->Sec_Board=0;
  236.         user->Sec_Library=tuser->B_Ratio;
  237.         user->Sec_Bulletin=0;
  238.         user->Sec_Status=tuser->Security;
  239.         user->Messages_Posted=tuser->Total_Posts;
  240.         strcpy(user->Conference_Access,"Normal");
  241.         user->Uploads=tuser->Total_ULFiles;
  242.         user->Downloads=tuser->Total_DLFiles;
  243.         user->ConfRJoin=1;
  244.         user->Times_Called=tuser->Total_Calls;
  245.         user->Time_Last_On=tuser->Time_Last_Logoff;
  246.         user->Time_Used=0;
  247.         user->Time_Limit=tuser->Limit_Time;
  248.         user->Time_Total=tuser->Limit_Time;
  249.         user->Bytes_Upload=tuser->Total_ULBytes;
  250.         user->Bytes_Download=tuser->Total_DLBytes;
  251.         user->Daily_Bytes_Limit=tuser->Limit_DLBytes;
  252.         user->Daily_Bytes_Dld=tuser->Period_DLBytes;
  253.         user->Expert=0;
  254.         user->NBytes_Upload=(double)tuser->Total_ULBytes;
  255.         user->NBytes_Download=(double)tuser->Total_DLBytes;
  256.         user->NDaily_Bytes_Limit=(double)tuser->Limit_DLBytes;
  257.         user->NDaily_Bytes_Dld=(double)tuser->Period_DLBytes;
  258.         user->Flag1=0;
  259.         user->Flag2=0;
  260.         user->FLag3=0;
  261.         user->EditorType=0;
  262.         user->BeginLogCall=0;
  263.         user->Protocol=0;
  264.         user->UUCPA=0;
  265.         user->New_User=0;
  266.         user->LineLength=tuser->Length;
  267.         
  268.         strcpy(userkeys->UserName,tuser->Name);
  269.         userkeys->Number=slot++;
  270.         userkeys->New_User=0;
  271.         userkeys->UPcps=0;
  272.         userkeys->DNcps=0;
  273.         userkeys->Userflags=0;
  274.         userkeys->baud_rate=tuser->LastBaudRate;
  275.         userkeys->QFlag=0;
  276.         userkeys->Who=0;
  277.         userkeys->MailScan=0;
  278.          userkeys->Language=0;
  279.         userkeys->QuietNode=0;
  280.         userkeys->MaxCalls=99;
  281.         userkeys->Called=1;
  282.         userkeys->ReplySkip=0;
  283.     
  284.         Write(writefh,user,sizeof(struct User));
  285.         Write(writefh2,userkeys,sizeof(struct UserKeys));
  286.     
  287.     }
  288. }
  289.  
  290.         if (readfh) Close(readfh);
  291.         if (writefh) Close(writefh);
  292.         if (writefh2) Close(writefh2);
  293.  
  294.         free(user);
  295.         free(tuser);
  296.         free(userkeys);
  297.  
  298.  
  299. }
  300.  
  301.  
  302.  
  303. void lowerstring(char *s)
  304. {
  305.     while((*s=tolower(*s)) != '\0') s++;
  306. }
  307. void upperstring(char *s)
  308. {
  309.     while((*s=toupper(*s)) != '\0') s++;
  310. }
  311.